package com.wish.g01.contract.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wish.g01.base.entity.MOwner;
import com.wish.g01.base.service.IMOwnerService;
import com.wish.g01.common.core.utils.StringUtils;
import com.wish.g01.contract.dto.YzOwnerDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wish.g01.common.log.annotation.Log;
import com.wish.g01.common.log.enums.BusinessType;
import com.wish.g01.common.security.annotation.PreAuthorize;
import com.wish.g01.common.core.web.controller.BaseController;
import com.wish.g01.common.core.web.domain.AjaxResult;
import com.wish.g01.common.core.utils.poi.ExcelUtil;
import com.wish.g01.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author wish
 * @date 2022-05-30
 */
@RestController
@RequestMapping("/owner")
public class TMOwnerController extends BaseController
{
    @Autowired
    private IMOwnerService imOwnerService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = "system:owner:list2")
    @GetMapping("/list")
    public TableDataInfo list(YzOwnerDto yzOwnerDto)
    {
        QueryWrapper<MOwner> wrapper = new QueryWrapper<>();
        startPage();
        //业主姓名查询
        if(StringUtils.isNotEmpty(yzOwnerDto.getOwnerName())){
            wrapper.like("owner_name",yzOwnerDto.getOwnerName());
        }
        List<MOwner> ownerList = imOwnerService.list(wrapper);
        return getDataTable(ownerList);
    }

//    /**
//     * 导出【请填写功能名称】列表
//     */
//    @PreAuthorize(hasPermi = "system:owner:export")
//    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, TMOwner tMOwner) throws IOException
//    {
//        List<TMOwner> list = tMOwnerService.selectTMOwnerList(tMOwner);
//        ExcelUtil<TMOwner> util = new ExcelUtil<TMOwner>(TMOwner.class);
//        util.exportExcel(response, list, "owner");
//    }
//
//    /**
//     * 获取【请填写功能名称】详细信息
//     */
//    @PreAuthorize(hasPermi = "system:owner:query")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return AjaxResult.success(tMOwnerService.selectTMOwnerById(id));
//    }
//
//    /**
//     * 新增【请填写功能名称】
//     */
//    @PreAuthorize(hasPermi = "system:owner:add")
//    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody TMOwner tMOwner)
//    {
//        return toAjax(tMOwnerService.insertTMOwner(tMOwner));
//    }
//
//    /**
//     * 修改【请填写功能名称】
//     */
//    @PreAuthorize(hasPermi = "system:owner:edit")
//    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody TMOwner tMOwner)
//    {
//        return toAjax(tMOwnerService.updateTMOwner(tMOwner));
//    }
//
//    /**
//     * 删除【请填写功能名称】
//     */
//    @PreAuthorize(hasPermi = "system:owner:remove")
//    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(tMOwnerService.deleteTMOwnerByIds(ids));
//    }
}
